#ifndef __TM52F1376_BSP_H__
#define __TM52F1376_BSP_H__

#include "TM52F1376_sfr_config.h"
#include "hal_defs.h"

#define delay_10nop() \
	do                \
	{                 \
		_nop_();      \
		_nop_();      \
		_nop_();      \
		_nop_();      \
		_nop_();      \
		_nop_();      \
		_nop_();      \
		_nop_();      \
		_nop_();      \
		_nop_();      \
	} while (0)

#define delay_5nop() \
	do               \
	{                \
		_nop_();     \
		_nop_();     \
		_nop_();     \
		_nop_();     \
		_nop_();     \
	} while (0)

// #define CompressorState P2_1
// #define Reg_CompressorState(a) P2_1 = a
// #define Reg_HeatState(a) P2_0 = a
// #define Reg_FanState(a) P3_6 = a

#define CompressorState P3_3
#define Reg_CompressorState(a) P3_3 = a
#define Reg_HeatState(a) P2_5 = a

#ifdef FAN_PWM
#define Reg_FanState(a) FanPwm(a) // st( if(a) PWM0_Set_Duty() )
#else
#define Reg_FanState(a) P1_5 = a
#endif
#define SCL_0 P0_0 = 0
#define SCL_1 P0_0 = 1

#define SDA_0 P0_1 = 0
#define SDA_1 P0_1 = 1

extern void bsp_clock_init(void);
extern void Bsp_Gpio_init(void);
extern void Bsp_Timer0_init(void);
extern void Bsp_Led_init(void);

#ifdef FAN_PWM
extern void PWM0_Set_Prod(unsigned int prd);
extern void PWM0_Set_Duty(unsigned int duty);
#endif

#ifdef WTD
extern void Bsp_WDG_Init(void);
#endif
// extern void LED_Write_Seg(unsigned char seg_idx, unsigned char seg_data);
extern void TM1650_send(unsigned char saddr, unsigned char sdate);
extern void TM1650_SystemCmd(unsigned char light, unsigned char segMod, unsigned char WorkMod, unsigned char Onoff);

#endif
